<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
{include file='header.tpl' JS=$smarty.const.BAOGG_JS CSS=$smarty.const.BAOGG_CSS}        
        
        <script type="text/javascript"> 
          var form_url='{$form_url}';
	var  LANG={$LANG};
	{literal}
Ext.onReady(function(){

	
                
                
                var form = new Ext.FormPanel({
                    url: form_url,
                    region: 'north',
                    el: "form",
                    frame: true,
		    bodyBorder :false,
                    bodyStyle: 'padding:15px 15px 0;',
                    height: 120,
                    items: [{
                        layout: 'column',
                        
                        items: [{
                            columnWidth: '0.3',
                            layout: 'form',
                            
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: LANG.model_name,
                                name: 'model_name',
                                anchor: '95%'
                            }, {
                                xtype: 'textfield',
                                fieldLabel: LANG.ext_table,
                                name: 'ext_table',
                                anchor: '95%'
                            }]
                        }, {
                            columnWidth: '0.3',
                            layout: 'form',
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: LANG.description,
                                name: 'description',
                                anchor: '95%'
                            },{
                                xtype: 'textfield',
                                fieldLabel: LANG.state,
                                name: 'state',
                                anchor: '95%'
                            }]
                        }, {
                            columnWidth: '0.3',
                            layout: 'form',
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: LANG.main_table,
                                name: 'main_table',
                                anchor: '95%'
                            },{
                                xtype: 'textfield',
                                fieldLabel: LANG.ordering,
                                name: 'ordering',
                                anchor: '95%'
                            },{
                                xtype: 'hidden',
                                name: 'model_id',
                                anchor: '95%'
                            }]
                        }]
                    }],
                    
                    buttons: [{
                        text: LANG.save,
			handler :function(b,e){
				form.getForm().submit({
				    clientValidation: true,				  
				  
				    success: function(form, action) {					
				       top.Ext.example.msg(LANG.save_ok, action.result.msg);
				       grid.getStore().load()					
				    },
				    failure: function(form, action) {
					switch (action.failureType) {
					    case Ext.form.Action.CLIENT_INVALID:
						top.Ext.example.msg(LANG.failure, "Form fields may not be submitted with invalid values");
						break;
					    case Ext.form.Action.CONNECT_FAILURE:
						top.Ext.example.msg(LANG.failure, "Ajax communication failed");
						break;
					    case Ext.form.Action.SERVER_INVALID:
					       top.Ext.example.msg(LANG.failure, action.result.msg);
					       break;
					    default:
					      top.Ext.example.msg(LANG.failure, action.result.msg);
					      break;
				       }
				    }
				});
			}
                    }, {
                        text: LANG.search,
			handler:function(b,e){
				grid.getStore().load(Ext.apply(grid.getStore().baseParams,form.getForm().getValues()));
			}
                    }, {
                        text: LANG.reset,
			handler:function(b,e){form.getForm().reset();}
                    }]
                });
{/literal}
	{$grid}
{literal}
		


	 Ext.create('Ext.container.Viewport', {
    layout: 'border',
    renderTo: Ext.getBody(),
                    items: grid				
                });
		win_form.show().center().hide();

});
</script>
{/literal}
 
</head>
<body>
  
       
<div id="form"></div>
<div id="grid"></div>


</body>
</html>